﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SD.App.Desktop.Entity
{
    [SugarTable("t_user")] // PgSQL 表名建议小写（默认不区分大小写，避免冲突）
    public class User
    {
        /// <summary>
        /// 主键（自增，PgSQL 用 SERIAL 类型）
        /// </summary>
        [SugarColumn(
            IsPrimaryKey = true,
            IsIdentity = true
        )]
        public long Id { get; set; }

        /// <summary>
        /// 用户名（唯一，PgSQL 字符串用 VARCHAR）
        /// </summary>
        [SugarColumn(
            IsNullable = false,
            Length = 20,
            ColumnDescription = "用户名"
        )]
        public string Username { get; set; } = string.Empty;

        /// <summary>
        /// 密码（加密存储，VARCHAR(64) 适配 SHA256 哈希值）
        /// </summary>
        [SugarColumn(
            IsNullable = false,
            Length = 64,
            ColumnDescription = "密码（SHA256 加密）"
        )]
        public string Password { get; set; } = string.Empty;

        /// <summary>
        /// 邮箱（可空，VARCHAR(50)）
        /// </summary>
        [SugarColumn(
            IsNullable = true,
            Length = 50,
            ColumnDescription = "邮箱"
        )]
        public string Email { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间（PgSQL 用 TIMESTAMP 类型）
        /// </summary>
        [SugarColumn(
            IsNullable = false,
            ColumnDescription = "创建时间",
            ColumnDataType = "TIMESTAMP" // 显式指定类型（可选）
        )]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否激活（PgSQL 布尔类型为 BOOLEAN）
        /// </summary>
        [SugarColumn(
            IsNullable = false,
            ColumnDescription = "是否激活",
            ColumnDataType = "BOOLEAN" // 可选，SqlSugar 自动映射
        )]
        public bool IsActive { get; set; } = true;
    }
}
